<?php
	if (!empty($banner['AdsBanner'])) {
		switch ($banner['AdsBanner']['kind']) {
			case 'I':
				$path = Configure::read('LilAds.uploadFolder');
				if (substr($path, 0, strlen(WWW_ROOT)) == WWW_ROOT) {
					// banner is in WWW_ROOT, display it directly
					$ad_url = Router::url('/', true) . strtr(substr($path, strlen(WWW_ROOT)), DS, '/') . $banner['AdsBanner']['filename'];
				} else {
					$ad_url = $this->Html->url(array(
						'plugin'     => 'lil_ads',
						'controller' => 'ads_banners',
						'action'     => 'display',
						$banner['AdsBanner']['id']
					), true);
				}
				$ad_image = $this->Html->image(
					$ad_url,
					array(
						'width'  => !empty($banner['AdsLocation']['width'])  ? $banner['AdsLocation']['width']  : null,
						'height' => !empty($banner['AdsLocation']['height']) ? $banner['AdsLocation']['height'] : null,
					)
				);
				
				if (!empty($banner['AdsBanner']['link'])) {
					echo $this->Html->link(
						$ad_image,
						array('plugin' => 'lil_ads', 'controller' => 'ads_banners', 'action' => 'click', $banner['AdsBanner']['id']), 
						array('escape' => false)
					);
				} else {
					echo $ad_image;
				}
				
				break;
			case 'F':
				if (substr($path, 0, strlen(WWW_ROOT)) == WWW_ROOT) {
					// banner is in WWW_ROOT, display it directly
					$ad_url = Router::url('/', true) . substr($path, strlen(WWW_ROOT)) . '/' . $banner['AdsBanner']['filename'];
				} else {
					$ad_url = $this->Html->url(array(
						'plugin'     => 'lil_ads',
						'controller' => 'ads_banners',
						'action'     => 'display',
						$banner['AdsBanner']['id']
					), true);
				}
				echo '<object type="application/x-shockwave-flash" data="'.$ad_url.'"'.(!empty($banner['AdsLocation']['width'])?' width="'.$banner['AdsLocation']['width'].'"':'').(!empty($banner['AdsLocation']['height'])?' height="'.$banner['AdsLocation']['height'].'"':'').'>';
					echo '<param name="movie" value="'.$ad_url.'" />';
					echo '<param name="quality" value="high"/>';
				echo '</object>';
				break;
			case 'P':
				echo h($banner['AdsBanner']['body']);
				break;
			case 'H':
				echo $banner['AdsBanner']['body'];
				break;
		}
	}
?>